#include <stdio.h>
#include "oled.h"
#include "gui.h"
#include "test.h"

void printString(int x,int y,int font_size,char *str){
    char *tmp_str = str;
    int cur_x=x;
    int cur_y=y;
    while(*tmp_str != '\0')
    {
        unsigned char csize = font_size;
        if(tmp_str[0] > 0){
           if(font_size == 16)
            {
                csize = font_size/2;
            }
            else if(font_size == 8)
            {
                csize = font_size/2+2;
            }
      
            GUI_ShowChar(cur_x,cur_y,tmp_str[0],font_size,1);
            tmp_str++;
        }else{

            if(font_size == 16)
            {
                GUI_ShowFont16(cur_x,cur_y,tmp_str,1);
            }else if(font_size == 24){
                //自己实现
                
            }
            tmp_str +=3;
        
        }
        
        cur_x += csize;
        if(cur_x > WIDTH-font_size)
		{
			cur_x=0;
			cur_y+=font_size;
		}
    }
}
// width: 64, height: 64
// const unsigned char logo[]  = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xf8,0xc0,0x00,0x7f,0xff,0xc0,0x00,0x1f,0xff,0xe0,0x00,0xff,0xff,0xe0,0x00,0x7f,0xff,0xe0,0x00,0xff,0xff,0xe0,0x00,0xff,0xff,0xe0,0x00,0xff,0xff,0xe0,0x01,0xf8,0x07,0xe0,0x00,0x00,0x03,0xc0,0x01,0xf0,0x03,0xe0,0x00,0x00,0x07,0xc0,0x03,0xe0,0x01,0xe0,0x00,0x00,0x07,0x80,0x07,0xc0,0x01,0xe0,0x00,0x00,0x0f,0x00,0x07,0xc0,0x01,0xe0,0x00,0x00,0x1f,0x00,0x07,0x80,0x01,0xe0,0x00,0x00,0x1e,0x00,0x0f,0x80,0x01,0xe0,0x00,0x00,0x3e,0x00,0x0f,0x00,0x01,0xe0,0x00,0x00,0x7c,0x00,0x0f,0x00,0x01,0xe0,0x00,0x00,0x78,0x00,0x0f,0x00,0x01,0xe0,0x00,0x00,0xf8,0x00,0x0f,0x00,0x01,0xe0,0x00,0x01,0xf0,0x00,0x0f,0x00,0x01,0xe0,0x00,0x01,0xe0,0x00,0x0f,0x00,0x01,0xe0,0x00,0x03,0xe0,0x00,0x0f,0x00,0x01,0xe0,0x00,0x07,0xc0,0x00,0x0f,0x00,0x01,0xe0,0x00,0x07,0x80,0x00,0x0f,0x80,0x01,0xe0,0x00,0x0f,0x80,0x00,0x0f,0x80,0x01,0xe0,0x00,0x0f,0x00,0x00,0x07,0x80,0x01,0xe0,0x00,0x1e,0x00,0x00,0x07,0xc0,0x01,0xe0,0x00,0x3e,0x00,0x00,0x07,0xc0,0x01,0xe0,0x00,0x3c,0x00,0x00,0x03,0xe0,0x01,0xe0,0x00,0x78,0x00,0x00,0x03,0xf0,0x03,0xe0,0x00,0xf8,0x00,0x00,0x01,0xf8,0x07,0xe0,0x00,0xf0,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x7f,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x1f,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x07,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
// width: 64, height: 64
const unsigned char logo[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xff,0xe0,0x00,0xff,0xff,0xe0,0x00,0x7f,0xff,0xe0,0x00,0xff,0xff,0xe0,0x00,0xff,0xff,0xe0,0x00,0xff,0xff,0xe0,0x01,0xf8,0x07,0xe0,0x00,0x00,0x03,0xc0,0x01,0xf0,0x03,0xe0,0x00,0x00,0x07,0xc0,0x03,0xe0,0x01,0xe0,0x00,0x00,0x07,0x80,0x07,0xc0,0x01,0xe0,0x00,0x00,0x0f,0x00,0x07,0x80,0x01,0xe0,0x00,0x00,0x1f,0x00,0x07,0x80,0x01,0xe0,0x00,0x00,0x1e,0x00,0x0f,0x80,0x01,0xe0,0x00,0x00,0x3c,0x00,0x0f,0x00,0x01,0xe0,0x00,0x00,0x7c,0x00,0x0f,0x00,0x01,0xe0,0x00,0x00,0x78,0x00,0x0f,0x00,0x01,0xe0,0x00,0x00,0xf8,0x00,0x0f,0x00,0x01,0xe0,0x00,0x01,0xf0,0x00,0x0f,0x00,0x01,0xe0,0x00,0x01,0xe0,0x00,0x0f,0x00,0x01,0xe0,0x00,0x03,0xe0,0x00,0x0f,0x00,0x01,0xe0,0x00,0x03,0xc0,0x00,0x0f,0x00,0x01,0xe0,0x00,0x07,0x80,0x00,0x0f,0x00,0x01,0xe0,0x00,0x0f,0x80,0x00,0x0f,0x80,0x01,0xe0,0x00,0x0f,0x00,0x00,0x07,0x80,0x01,0xe0,0x00,0x1e,0x00,0x00,0x07,0x80,0x01,0xe0,0x00,0x3e,0x00,0x00,0x07,0xc0,0x01,0xe0,0x00,0x3c,0x00,0x00,0x03,0xe0,0x01,0xe0,0x00,0x78,0x00,0x00,0x01,0xf0,0x03,0xe0,0x00,0xf8,0x00,0x00,0x01,0xf8,0x07,0xe0,0x00,0xf0,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x7f,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x1f,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x07,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
// #include "../../temp_humi_demo/motor.h"
// #include "../../temp_humi_demo/light.h"
#include "../temp_humi_demo/temp.h"

char temp_str[40]={0};
char humi_str[40]={0};
char fan_str[40]={0};
char light_str[40]={0};

#define SHOW_STRING "OpenHarmony"
void test_led_screen(void)
{	
  
    printf("before oled clear \r\n");
    OLED_Init();			   //初始化OLED  
  

    while(1){    
      //  OLED_Clear(0);             
        OLED_Clear(0);    //清屏（全黑）

        // GUI_FillTriangel(0,0,10,10,18,40,1);
        // GUI_ShowNum(22,0,1234,4,16,1);

        // GUI_ShowString(40,30,SHOW_STRING, 16 ,1  );
        // int x=0;
        // int y=0;
        // while(1){
        //     OLED_Clear(0);  
        //     GUI_DrawCircle(x, y, 1, 5);
        //     x +=2;
        //     y   +=1;
        //     OLED_Display();
        //     usleep(100*1000);
        // }
        // GUI_ShowChinese(0,0,16,"鸿蒙温度",1);
        

        sprintf(temp_str,"温度:%.02fC",g_temp);
        sprintf(humi_str,"湿度:%.02f%%",g_humi);

        printString(0,0,16,temp_str);
        printString(0,16,16,humi_str);
      
        OLED_Display();
        sleep(5);

    }
   
}

